/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.lujotar.ejb;

import com.lujotar.entities.Canjeo;
import com.lujotar.entities.Tarjeta;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author RamiroHenao
 */
@Stateless
public class CanjeoFacade extends AbstractFacade<Canjeo> {
    @PersistenceContext(unitName = "LUJOTAR-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CanjeoFacade() {
        super(Canjeo.class);
    }
    
    public List<Canjeo> consultarCanjeoTarjeta(Tarjeta id_tarjeta){
        Query query;
        query = em.createNamedQuery("Canjeo.findByTarjeta");
        query.setParameter("id_tarjeta",id_tarjeta);
        return query.getResultList();
    }
    
    public List<Canjeo> consultarCanjeos(){
        Query query;
        query = em.createNamedQuery("Canjeo.findAll");
        return query.getResultList();
    }
    
    public void crearCanjeo(Canjeo canjeo){
        em.persist(canjeo);
    }
    
    public void eliminarCanjeo(Canjeo canjeo){
        em.remove(canjeo);
    }
}
